<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <style>
        html, body {
            height: 100%;
            padding: 0;
            margin: 0;
            overflow: hidden;
        }

        body {
            font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC",
            "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;
        }

        .item {
            border: 1px solid #dcdcdc;
            box-sizing: border-box;
            width: 100%;
            height: 100%;
        }

        .icon {
            display: block;
            width: 66px;
            height: 66px;
            background-image: url("./@accessory.png");
            background-size: 40px;
            background-position: center;
            background-repeat: no-repeat;

        }

        .right {
            display: block;
            position: absolute;
            left: 100vh;
            top: 0;
            width: calc(100% - 101px);
            height: 100vh;
            padding: 8px 10px;
            box-sizing: border-box;
        }

        .text {
            width: calc(100% - 20px);
            color: #595959;
            font-size: 14px;
            position: absolute;
            margin: 10px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            left: 0;
        }

        #name {
            top: 0;
        }

        #size {
            bottom: 0;
        }

        .download {
            display: block;
            position: absolute;
            top: 22px;
            right: 10px;
            width: 24px;
            height: 24px;
            background-image: url("./@download.png");
            background-size: contain;
            background-position: center;
            background-repeat: no-repeat;
        }
    </style>
</head>
<div class="item">
    <div class="icon"></div>
    <div class="right">
        <p id="name" class="text"></p>
        <p id="size" class="text"></p>
    </div>
    <a class="download" id="download" target="_blank"></a>
</div>
<body>
<script type="text/javascript" src="../../vendor/base64/base64.min.js"></script>
<script type="text/javascript">
    var params = JSON.parse(Base64.decode(window.location.hash.substring(1)));
    function fileSizeFormat(fileSize) {
        let formattedSize = '';
        if (fileSize < 1024) {
            formattedSize = fileSize + 'B';
        } else if (1024 <= fileSize && fileSize < 1048576) {
            formattedSize = (fileSize / 1024).toFixed(2) + 'KB';
        } else if (1048576 <= fileSize && fileSize < 1073741824) {
            formattedSize = (fileSize / 1048576).toFixed(2) + 'MB';
        } else {
            formattedSize = (fileSize / 1073741824).toFixed(2) + 'GB';
        }
        return formattedSize;
    }
    document.querySelector('#size').innerHTML = fileSizeFormat(params.size);
    document.querySelector('#name').innerHTML = params.name;
    document.querySelector('#download').setAttribute('href', params.source);
</script>
</body>
</html>